package edu.chinasoft.service;

import edu.chinasoft.domain.Dept;
import edu.chinasoft.domain.PageUnitForDept;
import edu.chinasoft.mapper.DeptMapper;
import edu.chinasoft.mapper.UserMapper;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.web.server.ServerErrorException;

import java.util.List;
import java.util.Map;

@Service("deptService")
public class DeptServiceImp implements DeptService {
    @Autowired
    @Qualifier(value = "deptMapper")
    private DeptMapper deptMapper;
    private UserMapper userMapper;
    private Logger logger = LoggerFactory.getLogger(DeptServiceImp.class);

    @Override
    public Boolean insertDept(Dept dept){
        logger.info("DeptServiceImp>>>insertDept start ……");
        Boolean result = deptMapper.insertDept(dept);
        logger.info("DeptServiceImp>>>insertDept end ……");
        return result;
    }

    @Override
    public Dept selectDeptByDeptId(Dept dept){
        logger.info("DeptServiceImp>>>updateDeptById start ……");
        Dept result = deptMapper.selectDeptByDeptId(dept);
        logger.info("DeptServiceImp>>>updateDeptById end ……");
        return result;
    }
    @Override
    public Boolean updateDeptById(Dept dept){
        logger.info("DeptServiceImp>>>updateDeptById start ……");
        Boolean result = deptMapper.updateDeptById(dept);
        logger.info("DeptServiceImp>>>updateDeptById end ……");
        return result;
    }
    @Override
    public Boolean deleteDeptById(Dept dept){
        logger.info("DeptServiceImp>>>deleteDeptById start ……");
        Boolean result = deptMapper.deleteDeptById(dept);
        logger.info("DeptServiceImp>>>deleteDeptById end ……");
        return result;
    }

    @Override
    public PageUnitForDept getRecordNum(){
        logger.info("DeptServiceImp>>>getRecordNum start ……");
        PageUnitForDept recordNum = deptMapper.getRecordNum();
        logger.info("DeptServiceImp>>>getRecordNum end ……");
        return recordNum;
    }
    @Override
    public List<Dept> selectUnitDept(Map<String,Object> map){
        logger.info("DeptServiceImp>>>selectUnitDept start ……");
        List<Dept> deptList = deptMapper.selectUnitDept(map);
        logger.info("DeptServiceImp>>>selectUnitDept end ……");
        return deptList;
    }

    @Override
    public List<Dept> selectDept(){
        logger.info("DeptServiceImp>>>selectUnitDept start ……");
        List<Dept> deptList = deptMapper.selectDept();
        logger.info("DeptServiceImp>>>selectUnitDept end ……");
        return deptList;
    }

}

